package cn.iocoder.yudao.module.trade.framework.delivery.excel;

import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.excel.core.function.ExcelColumnSelectFunction;
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
import cn.iocoder.yudao.module.trade.enums.ExcelColumnSelectNameConstants;
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@Component
public class DeliveryExcelColumnSelectFunction implements ExcelColumnSelectFunction {

    @Resource
    private DeliveryExpressService deliveryExpressService;

    @Override
    public String getName() {
        return ExcelColumnSelectNameConstants.DELIVERY_EXCEL_COLUMN_SELECT;
    }

    @Override
    public List<String> getOptions() {
        return deliveryExpressService.getDeliveryExpressListByStatus(CommonStatusEnum.ENABLE.getStatus())
                .stream().map(DeliveryExpressDO::getName).collect(Collectors.toList());
    }
}
